const readline = require('readline');
const rl = readline.createInterface({ input: process.stdin });
let input = [];

rl.on('line', line => input.push(line.trim()));
rl.on('close', () => {
  let idx = 0;
  const T = parseInt(input[idx++]);

  for (let t = 0; t < T; t++) {
    const n = BigInt(input[idx++]);
    
    // 递归计算面额为n的钞票最终会产生多少个0
    // 使用记忆化优化
    const memo = new Map();
    
    function countZeros(value, count) {
      if (value === 0n) return count;
      if (value === 1n) return 0n;
      
      // 拆分：⌊value/2⌋, value%2, ⌊value/2⌋
      const half = value / 2n;
      const mod = value % 2n;
      
      let result = 0n;
      
      // value%2 如果是0，会产生 count 个0
      if (mod === 0n) {
        result += count;
      }
      
      // 2个⌊value/2⌋继续拆分
      result += countZeros(half, 2n * count);
      
      return result;
    }
    
    console.log(countZeros(n, 1n).toString());
  }
});

